/*
 * FNISVGEditor - JavaScript - based editor for SVG graphics 
 * Copyright (C) 2008 - 2009 Antti Leppä / Foyt
 * http://www.foyt.fi
 * 
 * License: 
 * 
 * Licensed under GNU Lesser General Public License Version 2.1 or later (the "LGPL") 
 * http://www.gnu.org/licenses/lgpl.html
 */
FNISVGEditorViewPortChangeUndoController = Class.create(FNISVGEditorUndoController, {
  initialize: function ($super) { 
    $super();
  },
  undo: function (editorInstance, event) {       
    // if redo data is not set yet, we set it now
    if (!event.newViewBox)
      event.newViewBox = editorInstance.getViewPort().getViewBox();
    
    var viewBox = event.oldViewBox;    
    editorInstance.getViewPort().setViewBox(viewBox.x, viewBox.y, viewBox.width, viewBox.height);    
  },
  redo: function (editorInstance, event) { 
    var viewBox = event.newViewBox;    
    editorInstance.getViewPort().setViewBox(viewBox.x, viewBox.y, viewBox.width, viewBox.height);    
  },
  getEventType: function () {
    return 'viewportChange';
  }
});

GetFNISVGEditorUndoEventControllerVault().registerController(new FNISVGEditorViewPortChangeUndoController());
